'''
Created on Oct 14, 2012

@author: raygomez
'''
import unittest
from Unsigned32AVP import Unsigned32AVP
from Error import InvalidAVPLengthError
from AVP import AVP


class Test(unittest.TestCase):


    def testUnsigned32AVP(self):
        a = Unsigned32AVP(1, 0x12)
        self.assertEqual("1:18", str(a))
        

    def testSetGetValue(self):
        a = Unsigned32AVP(1, 0x12)
        self.assertEqual(18, a.getValue())
        a.setValue(0x34)
        self.assertEqual(0x34, a.getValue())

    def testConvert(self):
        a = Unsigned32AVP(1, 0x12345678)
        b = Unsigned32AVP.convert(a)
        self.assertEqual(a.code, b.code)
        self.assertEqual(a.flags, b.flags)
        
    def testConvertException(self):
        a = AVP(1, "12345")
        
        self.assertRaises(InvalidAVPLengthError, Unsigned32AVP.convert, a)
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()